export default {
  state: {
    get token() {
      let token = sessionStorage.getItem('token');
      return token === 'undefined' || token === undefined ? null : token;
    },
    set token(val) {
      sessionStorage.setItem('token', val)
    },
    // ---角标 start
    get cartGoodsNum() {
      let cartGoodsNum = sessionStorage.getItem('cartGoodsNum');
      return cartGoodsNum === 'undefined' || cartGoodsNum === undefined ? null : Number.parseInt(cartGoodsNum)
    },
    set cartGoodsNum(val){
      sessionStorage.setItem('cartGoodsNum', val)
    },
    get ordersNum() {
      let ordersNum = sessionStorage.getItem('ordersNum');
      return ordersNum === 'undefined' || ordersNum === undefined ? null : JSON.parse(ordersNum)
    },
    set ordersNum(val){
      sessionStorage.setItem('ordersNum', JSON.stringify(val))
    },
    // ---角标 end
    get buyList() {
      let buyList = sessionStorage.getItem('buyList');
      return buyList === 'undefined' || buyList === undefined ? null : JSON.parse(buyList);
    },
    set buyList(val){
      sessionStorage.setItem('buyList', JSON.stringify(val))
    },
    get orderCodes() {
      let orderCodes = sessionStorage.getItem('orderCodes');
      return orderCodes === 'undefined' || orderCodes === undefined ? null : JSON.parse(orderCodes);
    },
    set orderCodes(val){
      sessionStorage.setItem('orderCodes', JSON.stringify(val))
    },
    get cartSubmitFlag() {
      let cartSubmitFlag = sessionStorage.getItem('cartSubmitFlag');
      return cartSubmitFlag === 'undefined' || cartSubmitFlag === undefined ? null : JSON.parse(cartSubmitFlag);
    },
    set cartSubmitFlag(val){
      sessionStorage.setItem('cartSubmitFlag', JSON.stringify(val))
    }
  }
}
